﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Group_73.Games_Manager;

namespace Group_73
{
    //Font chữ
    public class Fonts
    {
        public static SpriteFont TitleFont { get; set; }
        public static SpriteFont MenuFont { get; private set; }
        public static SpriteFont ButtonFont { get; private set; }

        public static SpriteFont MainFont { get; private set; }
        public static SpriteFont HeaderFont { get; private set; }

        static public readonly Color SkillNameColor = Color.Orange;
        static public readonly Color SkillDescriptionColor = Color.Wheat;
        static public readonly Color SkillStatColor = Color.LightGreen;

        public static void LoadContent()
        {
            ContentManager contentManager = GameLoader.Content;

            ButtonFont = contentManager.Load<SpriteFont>("Fonts/ButtonFont");
            TitleFont = contentManager.Load<SpriteFont>("Fonts/TitleFont");
            MenuFont = contentManager.Load<SpriteFont>("Fonts/MenuFont");

            MainFont = contentManager.Load<SpriteFont>("Fonts/MainFont");
            HeaderFont = contentManager.Load<SpriteFont>("Fonts/HeaderFont");
        }

        public static void DrawCenterText(SpriteBatch spriteBatch, SpriteFont font,
            string text, Vector2 position, Color color)
        {
            if (spriteBatch == null)
            {
                throw new ArgumentNullException("spriteBatch");
            }

            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            if (String.IsNullOrEmpty(text))
            {
                return;
            }

            Vector2 textSize = font.MeasureString(text);
            Vector2 centerPosition = new Vector2(position.X-(int)textSize.X/2,
                                                 position.Y - (int)textSize.Y/2);

            spriteBatch.DrawString(font, text, centerPosition, color, 0f,
                Vector2.Zero, 1f, SpriteEffects.None, 1f - position.Y / 720f);
        }

        public static Vector2 GetCenterPositionInButton(SpriteFont font, string text, Rectangle buttonPosition)
        {
            Vector2 positionOfText = Vector2.Zero;

            Vector2 fontSize = font.MeasureString(text);
            positionOfText.X = buttonPosition.X + buttonPosition.Width / 2 - fontSize.X / 2;
            positionOfText.Y = buttonPosition.Y + buttonPosition.Height / 2 - fontSize.Y / 2;

            return positionOfText;
        }

    }
}
